<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
	public function index() {
            if($this->session->userdata('isLoggedIn')) {
                $data['scripts'] = array('person');
                $this->load->view('crm/person',$data);                 
            }
            else {
                redirect('login');
            }
           
	}
        
        public function showAddPersonForm(){
            echo json_encode($data);
        }
        
        public function  hideAddPersonForm(){
            echo json_encode($data);
        }

        public function addPerson(){
            $personRoll = $this->input->post('personRoll');
            $personName = $this->input->post('personName');
            $personLastName = $this->input->post('personLastName');
            $personPhone = $this->input->post('personPhone');
            $personEmail = $this->input->post('personEmail');
            $personFunction = $this->input->post('personFunction');
            $personAddPartner = $this->input->post('personAddPartner');
            $personFile = $this->input->post('personFile');
            $personLeading = $this->input->post('personLeading');
            $personAddress = $this->input->post('personAddress');
            $personPostalcode = $this->input->post('personPostalcode');
            $personCity = $this->input->post('personCity');
            $personExtra = $this->input->post('personExtra');
            $personPhone = $this->input->post('personFacebook');
            $personPhone = $this->input->post('personTwitter');
            $personPhone = $this->input->post('personLinkedin');
            $personPhone = $this->input->post('personOther');
            
            if(!$personName || !$personLastName){
                 $data['error'] = 'Please fill in all required fields.';
                echo json_encode($data);
            }
            else{
                echo json_encode($data);
                $this->load->model('personModel');
                $this->personModel->addPerson($person);
                
            }
        }
        
}